<extend name="Extends/base" />
<block name="title">编辑用户信息</block>
<block name="css">
</block>
<block name="body_style"> class="bgc-ff4"</block>
<block name="body">
    <div class="c-main pb20">
        <div class="mechanism">
            <img src="__APPS__/images/introduce.jpg">
            <div class="fill-txt">
                <form id='myForm'>
                    <ul class="fill-list">
                        <li>
                            <div class="fill-list-key">姓名</div>
                            <div class="fill-list-info">
                                <input type="text" class="fill-input" value="{$info.name}" disabled="true" />
                            </div>
                        </li>
                        <li>
                            <div class="fill-list-key">出生日期</div>
                            <div class="fill-list-info fill-rt">
                                <empty name="info['birthday']">
                                    <input type="text" name="birthday" class="fill-input" placeholder="请选择出生日期" value=""
                                        data-time="date">
                                    <else />
                                    <input name="birthday" type="text" class="fill-input" placeholder="请选择出生日期"
                                        value="{:date('Y-m-d',strtotime($info['birthday']))}" data-time="date">
                                </empty>

                            </div>
                        </li>
                        <li>
                            <div class="fill-list-key">所在城市</div>
                            <div class="fill-list-info fill-rt">
                                <if condition="empty($info['prov']) OR empty($info['city']) ">
                                    <input type="text" class="fill-input" name="area" placeholder="请选择城市" value=""
                                        data-time="area">
                                    <else />
                                    <input type="text" class="fill-input" name="area" placeholder="请选择城市"
                                        value="{$info['prov']} {$info['city']}" data-time="area">
                                </if>

                            </div>
                        </li>
                    </ul>
                </form>
                <!-- S fill-btn -->
                <div class="fill-btn">
                    <a class="submit-user-btn" href="javascript:;">提交</a>
                </div>
                <!-- E fill-btn -->
            </div>
            <!-- E mechanism-txt -->

        </div>
        <!-- E mechanism -->
    </div>
</block>
<block name="js">
    <link rel="stylesheet" href="__APPS__/widget/mobiscroll/2.17.1/css/mobiscroll.css?v={:C('JS_CSS_VERSION')}" />
    <script type="text/javascript"
        src="__APPS__/widget/mobiscroll/2.17.1/js/mobiscroll.min.js?v={:C('JS_CSS_VERSION')}"></script>
    <link rel="stylesheet" href="__APPS__/widget/cmarea/css/cmarea.css?v={:C('JS_CSS_VERSION')}" />
    <script type="text/javascript" src="__APPS__/widget/cmarea/js/cmarea.js?v={:C('JS_CSS_VERSION')}"></script>

    <script type="text/javascript" src="__APPS__/js/api.js?v={:C('JS_CSS_VERSION')}"></script>
    <script type="text/javascript">
        // 选择出生日期
        $('input[data-time=date]').mobiscroll({
            preset: 'date',
            theme: 'ios',
            dateFormat: 'yy-mm-dd',
            lang: 'zh',
            maxDate: new Date()
        });

        //选择地区
        $('input[data-time=area]').cmArea({
            full: true,
            zone: false
        });

        $('.submit-user-btn').on("click", function () {
            var area = $('input[name=area]').val();
            var birthday = $('input[name=birthday]').val();

            if(!$.trim(area)){
                $.toast("请选择区域");
                return false;
            }

            if(!$.trim(birthday)){
                $.toast("请选择生日");
                return false;
            }
            var data = {
                "area": area,
                "birthday": birthday
            }
            doEditUser(data, function (res) {
                if (res.Code != 10000) {
                    $.toast(res.Message);
                    return false;
                }

                $.toast("提交成功", 1000, function () {
                    location.href = $.sUrl("/Survey/goWall");
                })
            });
        });
    </script>
</block>